package intelligent_driver;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import java.util.ArrayList;

import javax.swing.JPanel;

public class Panel extends JPanel{
	
	private ArrayList<Ellipse2D> vehicles;
	private double str = 5;
	
	public Panel(int w, int h){
		setPreferredSize(new Dimension(w, h));
	}

	public void update(ArrayList<Vehicle> vq){
		vehicles = new ArrayList<Ellipse2D>();
		for(int i = 0; i < vq.size(); i++){
				double x = vq.get(i).position()+60;
				double y = 325;
				vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
	}
	
	public void paintComponent(Graphics g) {
		super.paintComponent(g);
	    Graphics2D ga = (Graphics2D)g;
	    ga.setPaint(Color.black);
	    for(Ellipse2D e : vehicles){
	    	ga.draw(e);
	    	ga.drawString("a"+vehicles.indexOf(e), (int)(e.getCenterX())-3, (int)(e.getCenterY())-3);
	    }
	    ga.drawLine(100, 325, 300, 325);
	}

}
